package com.qjl.shopping.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qjl.shopping.bean.Admin;
import com.qjl.shopping.bean.Game;
import com.qjl.shopping.bean.Star;
import com.qjl.shopping.dao.AdminMapper;
import com.qjl.shopping.dao.StarMapper;
import com.qjl.shopping.service.AdminService;
import com.qjl.shopping.service.StarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author liguanghui
 * @Date 2023/5/3
 */
@Service
public class StarServiceImpl extends ServiceImpl<StarMapper, Star> implements StarService {
    @Autowired
    private StarMapper starMapper;
    @Override
    public Page<Star> selectPage(int pageNum, int pageSize,int userId,int itemId) {
        Page<Star> page = new Page<>(pageNum,pageSize);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.orderByDesc("star_id");
        if (userId!=0){
            queryWrapper.eq("star_user_id",userId);
        }
        if (itemId!=0){
            queryWrapper.eq("star_item_id",itemId);
        }
        Page<Star> starPage = starMapper.selectPage(page,queryWrapper);
        return starPage;
    }
}
